﻿#region 命名空间

using System;
using WinnerCMS.BLL;
using WinnerCMS.Common;
using WinnerCMS.Model;
using WinnerCMS.Model.Attribute;

#endregion

namespace WinnerCMS.WebUI.Admin.Member
{
    [Access("269005")]
    public partial class Business : WebFactory.PageBase
    {
        private readonly BusinessManage _myBll = new BusinessManage();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindList(1);
            }
        }

        private void BindList(int pageNo)
        {
            this.GV_List.EmptyDataTemplate = GetTemplate(this);
            var pp = new PagingParam();
            pp.PageNo = pageNo;
            pp.PageSize = this.PageNavigation1.PageSize;
            var action = Request["Action"];

            if (action == "XiaoFei")
            {
                this.L_Path.Text = "会员管理 → 交易明细 → <a href=\"Business.aspx?Action=XiaoFei\">扣点数</a>";
                Title = "扣点数";

                this.GV_List.Columns[5].Visible = false;
                this.GV_List.Columns[6].Visible = false;

                this.GV_List.DataSource = this._myBll.BindList(1, pp);
                this.GV_List.DataBind();
            }
            else if (action == "HuiKuan")
            {
                this.L_Path.Text = "会员管理 → 交易明细 → <a href=\"Business.aspx?Action=HuiKuan\">汇款确认</a>";
                Title = "汇款确认";

                this.GV_List.Columns[4].Visible = false;

                this.GV_List.DataSource = this._myBll.BindList(0, pp);
                this.GV_List.DataBind();
            }
            else
            {
                ErrClass.Redirect("参数错误！");
            }

            this.PageNavigation1.RecordCount = pp.RecordCount;

            if (this.GV_List.Rows.Count <= 0)
            {
                this.btnDelSelected.Enabled = false;
            }
        }


        protected void btnDelSelected_Click(object sender, EventArgs e)
        {
            var res = this._myBll.Delete(GetSelectedRow.GetIDs(this.GV_List));

            if (res.Errors.Length > 0)
            {
                MsgBox.Message(res.Errors, this);
            }
            else
            {
                MsgBox.Message("删除成功！", "Business.aspx?Action=" + Request["Action"], this);
            }
        }

        protected void PageNavigation1_PageChanging(object src, WebControls.PageChangingEventArgs e)
        {
            BindList(e.NewPageIndex);
        }
    }
}